package com.lqfan.autoAnswerQ.service.reportCard.impl;

import com.lqfan.autoAnswerQ.model.reportCard.ReportCard;
import com.lqfan.autoAnswerQ.dao.reportCard.ReportCardMapper;
import com.lqfan.autoAnswerQ.service.reportCard.IReportCardService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author zml
 * @since 2020-05-04
 */
@Service
public class ReportCardServiceImpl extends ServiceImpl<ReportCardMapper, ReportCard> implements IReportCardService {

    public int insertRecordCard(String questionId, String score, String info, String name, String userId) {
        ReportCard reportCard = new ReportCard();
        reportCard.setQuestionId(questionId);
        reportCard.setScore(score);
        reportCard.setInfo(info);
        reportCard.setName(name);
        reportCard.setUserId(userId);
        boolean result = baseMapper.insertRecordCard(reportCard);
        if (result){
            return 1;
        }else {
            return 0;
        }

    }


    public List<ReportCard> getReportCard(String userId) {
        List<ReportCard> reportCards ;
        reportCards  = baseMapper.getReportCard(userId);
        return reportCards;
    }


    public List<ReportCard> getReportCardInfo(String userId, String questionId) {
        List<ReportCard> reportCards ;
        reportCards  = baseMapper.getReportCardInfo(userId,questionId);

        return reportCards;
    }


    public int deleteReportCard(String questionId, String userId) {
        boolean deleteReportCard = baseMapper.deleteReportCard(questionId,userId);
        if (deleteReportCard){
            return 1;
        }else {
            return 0;
        }

    }


    public int deleteReportCardInfo(String reportCardId, String userId) {
        boolean deleteReportCard = baseMapper.deleteReportCardInfo(reportCardId,userId);
        if (deleteReportCard){
            return 1;
        }else {
            return 0;
        }
    }
}
